import Layout from '@/layout'
import { queryCategoryApi, infoUserApi } from '@/api/user'

const TokenKey = 'qishi'// token名
const UserIdName = 'lvt_64ecd82404c51e0d'// userId名
const detailKey = 'lvt_64Deta04cd'// 行 详情
const roleIDKey = 'lvtecd'// role id
const headUrlKey = 'lvtehd'// headUrl

export function saveValue(key, value) {
  localStorage.setItem(key, JSON.stringify(value))
}

export function getValue(key) {
  return JSON.parse(localStorage.getItem(key))
}

export function removeAllSavedValue() {
  localStorage.removeItem(TokenKey)
  localStorage.removeItem(UserIdName)
  localStorage.removeItem(detailKey)
  localStorage.removeItem(roleIDKey)
  localStorage.removeItem(headUrlKey)
  localStorage.removeItem('categoryList')
  localStorage.removeItem('userEmail')
  localStorage.removeItem('userInfo')
  localStorage.removeItem('userName')
  localStorage.removeItem('headUrl')
  localStorage.removeItem('masterdealerId')
  localStorage.removeItem('mainCustomerId')
  localStorage.removeItem('saveMsg')
}

export function getToken() { return localStorage.getItem(TokenKey) ? localStorage.getItem(TokenKey) : null }
export function getUserName() { return localStorage.getItem(UserIdName) ? localStorage.getItem(UserIdName) : 'User' }
export function getroleID() { return localStorage.getItem(roleIDKey) ? localStorage.getItem(roleIDKey) : null }
export function getHeadUrl() { return localStorage.getItem(headUrlKey) ? localStorage.getItem(headUrlKey) : null }

export function saveToken(value) { localStorage.setItem(TokenKey, value) }
export function saveUserName(value) { localStorage.setItem(UserIdName, value) }
export function saveroleID(value) { localStorage.setItem(roleIDKey, value) }
export function saveHeadUrl(value) { localStorage.setItem(headUrlKey, value) }

export function removeroleID() { localStorage.removeItem(roleIDKey) }

export function setDetail(value) {
  localStorage.setItem(detailKey, JSON.stringify(value))
}

export function getDetail() {
  return JSON.parse(localStorage.getItem(detailKey))
}

export function removeDetail() {
  localStorage.removeItem(detailKey)
}

export function hasTokens() { // 是否登录 检查多项localStorage
  return !!(getToken() && getroleID())
}
export const isPhone = function() {
  return (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))
}
const requestData = {
  'pageNum': 200, // 分页条数
  'pageIndex': 1 // 页编码
}
export const getThousandNum = function(num) {
  if (num) {
    var str = num.toString()
    var reg = str.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g
    return str.replace(reg, '$1,')
  } else {
    return num
  }
}
export const getCategoryTypeList = function() {
  const categoryList = localStorage.getItem('categoryList') ? getValue('categoryList') : null
  if (categoryList) {
    return categoryList
  }
  queryCategoryApi(requestData).then(res => {
    if (res.data) {
      if (res.data.records) {
        if (res.data.records.length) {
          if (res.data.records.length > 0) {
            saveValue('categoryList', res.data.records)
            return res.data.records
          }
        }
      }
    }
    return null
  }).catch(err => {
    console.log(err)
    return null
  })
}
export const getUserInfo = function() {
  const userInfo = localStorage.getItem('userInfo') ? getValue('userInfo') : null
  if (userInfo) {
    return userInfo
  }
  infoUserApi().then(res => {
    saveValue('userInfo', res.data)
    return res.data
  }).catch(err => {
    console.log(err)
    return {
      name: 'User',
      headUrl: ''
    }
  })
}
export const getDateStr = function(time) {
  var m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Spt', 'Oct', 'Nov', 'Dec']
  var t = new Date(time)
  var month = t.getMonth()
  var day = t.getDate()
  const monthStr = m[month]
  var newTime = monthStr + ' ' + day
  return newTime
}
export const getTimeStr = function(time) {
  if (!time) {
    return time
  }
  var m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Spt', 'Oct', 'Nov', 'Dec']
  var t = new Date(time)
  var year = t.getFullYear()
  var month = t.getMonth()
  var day = t.getDate()
  const monthStr = m[month]
  var newTime = day + ' ' + monthStr + ' ' + year
  return newTime
}

export const downExcel = function(data, fileNmae) {
  if (fileNmae === null) {
    fileNmae = new Date().Format('yyyy-MM-dd') + '.xls'
  }
  if ('download' in document.createElement('a')) {
    const url = window.URL.createObjectURL(data)
    const link = document.createElement('a')
    link.style.display = 'none'
    link.href = url
    link.setAttribute('download', fileNmae)
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
  } else {
    navigator.msSaveBlob(data, fileNmae)
  }
}
export const accountTrim = function(str) {
  return str.replace(/(^\s+)|(\s+$)/g, '').replace(/\s/g, '')
}
export const keepTwoDecimalFull = function(num) {
  var result = parseFloat(num)
  result = Math.round(num * 100) / 100
  var s_x = result.toString()

  var pos_decimal = s_x.indexOf('.')
  if (pos_decimal < 0) {
    pos_decimal = s_x.length
    s_x += '.'
  }
  while (s_x.length <= pos_decimal + 2) {
    s_x += '0'
  }
  return s_x
}
export const getNumFormat = function(num) {
  num = num * 100
  const add = num % 10
  if (add) {
    num = num - add
    if (add > 2 && add < 8) {
      num = num + 5
    }
    if (add > 7) {
      num = num + 10
    }
  }
  num = num / 100
  num = keepTwoDecimalFull(num)
}

export const formatMoneyStr = function(num) {
  return 'RM ' + getThousandNum(keepTwoDecimalFull(num))
}

export const superAdminRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  },
  {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-lnvoice-edit'),
      meta: { title: 'Invois Pembelian Detail', title2: 'Perincian Invois Pembelian', icon: 'ico_purchase_invoice' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer-Master',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer-Master',
      component: () => import('@/views/customers/main-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/customers/customers-new'),
      meta: { title: 'Tambah', title2: 'Tambah', icon: 'ico_customer' }
    }]
  }, {
    path: '/Report',
    component: Layout,
    redirect: '/Report/General',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: '/Reports_Analytics',
      component: () => import('@/views/report/report'),
      meta: { title: 'Laporan Am', title2: 'Laporan/Analisis' }
    }, {
      path: 'Sales-Report',
      component: () => import('@/views/report/sales-report'),
      meta: { title: 'Laporan Jualan', title2: 'Laporan/Analisis' }
    }, {
      path: 'Product-Sales-Report',
      component: () => import('@/views/report/product-sales-report'),
      meta: { title: 'Laporan Jualan Produk', title2: 'Laporan/Analisis' }
    }, {
      path: 'Laporan Transaksi Online',
      component: () => import('@/views/report/online-transactior-report'),
      meta: { title: 'Laporan Transaksi Online', title2: 'Laporan/Analisis' }
    }]
  },
  {
    path: '/Log',
    component: Layout,
    redirect: '/Activity_Log',
    children: [{
      path: '/Activity-Log',
      component: () => import('@/views/activity-record'),
      meta: { title: 'Log Aktiviti', title2: 'Log Aktiviti', icon: 'ico_activity_log' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const bigAgentRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  }, {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer-Master',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer-Master',
      component: () => import('@/views/customers/main-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/customers/customers-new'),
      meta: { title: 'Tambah', title2: 'Tambah', icon: 'ico_customer' }
    }]
  },
  {
    path: '/Reports-Analytics',
    component: Layout,
    redirect: '/Reports-Analytics',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: '/Reports_Analytics',
      component: () => import('@/views/report/report'),
      meta: { title: 'Laporan Am', title2: 'Laporan/Analisis' }
    }, {
      path: 'Dealers',
      hidden: true,
      component: () => import('@/views/report/report-dealer'),
      meta: { title: 'Dealer', title2: 'Dealer' }
    }, {
      path: 'Sales-Report',
      component: () => import('@/views/report/sales-report'),
      meta: { title: 'Laporan Jualan', title2: 'Laporan/Analisis' }
    }, {
      path: 'Product-Sales-Report',
      component: () => import('@/views/report/product-sales-report'),
      meta: { title: 'Laporan Jualan Produk', title2: 'Laporan/Analisis' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    redirect: '/Company-Profile',
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/company-profile'),
      meta: { title: 'Profil Syarikat', title2: 'Profil Syarikat', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const mainDealerRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '',
      component: () => import('@/views/user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  }, {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/My-Orders',
    component: Layout,
    redirect: '/My-Orders/Query',
    meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' },
    children: [{
      path: 'Query',
      component: () => import('@/views/myorder/purchase-order'),
      meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/myorder/purchase-order-edit'),
      meta: { title: 'Pesanan', title2: 'Perincian Pesanan', icon: 'ico_my_order' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }]
  },
  {
    path: '/Shop',
    component: Layout,
    redirect: '/Shop/Query',
    meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' },
    children: [{
      path: 'Query',
      name: 'queryShop',
      component: () => import('@/views/shop/shop'),
      meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' }
    }, {
      path: 'Shopping-Cart',
      hidden: true,
      component: () => import('@/views/shop/shop-cart'),
      meta: { title: 'Troli Beli Belah', title2: 'Troli', icon: 'ico_shop' }
    }, {
      path: 'detail/:id',
      hidden: true,
      component: () => import('@/views/shop/shop-detail'),
      meta: { title: 'Perincian', title2: 'Perincian Barang', icon: 'ico_shop' }
    }, {
      path: 'Checkou',
      hidden: true,
      component: () => import('@/views/shop/shop-checkout'),
      meta: { title: 'Semak Keluar', title2: 'Semak Keluar', icon: 'ico_shop' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-lnvoice-edit'),
      meta: { title: 'Perincian', title2: 'Perincian Invois Pembelian', icon: 'ico_purchase_invoice' }
    }]
  }, {
    path: '/Reports-Analytics',
    component: Layout,
    redirect: '/Reports-Analytics',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: 'dealer',
      component: () => import('@/views/report/report-dealer'),
      meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/company-profile'),
      meta: { title: 'Profil Syarikat', title2: 'Profil Syarikat', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const smallDealerRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  },
  {
    path: '/My-Orders',
    component: Layout,
    redirect: '/My-Orders/Query',
    meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' },
    children: [{
      path: 'Query',
      component: () => import('@/views/myorder/purchase-order'),
      meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/myorder/purchase-order-edit'),
      meta: { title: 'Edit Pesanan Saya', title2: 'Perincian Pesanan', icon: 'ico_my_order' }
    }]
  },
  {
    path: '/Shop',
    component: Layout,
    redirect: '/Shop/Query',
    meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' },
    children: [{
      path: 'Query',
      name: 'queryShop',
      component: () => import('@/views/shop/shop'),
      meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' }
    }, {
      path: 'Shopping-Cart',
      hidden: true,
      component: () => import('@/views/shop/shop-cart'),
      meta: { title: 'Troli Beli Belah', title2: 'Troli', icon: 'ico_shop' }
    }, {
      path: 'detail/:id',
      hidden: true,
      component: () => import('@/views/shop/shop-detail'),
      meta: { title: 'Perincian', title2: 'Perincian Barang', icon: 'ico_shop' }
    }, {
      path: 'Checkou',
      hidden: true,
      component: () => import('@/views/shop/shop-checkout'),
      meta: { title: 'Semak Keluar', title2: 'Semak Keluar', icon: 'ico_shop' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/purchase-lnvoice-edit'),
      meta: { title: 'Perincian', title2: 'Perincian Invois', icon: 'ico_purchase_invoice' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    redirect: '/Company-Profile',
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/company-profile'),
      meta: { title: 'Profil Saya', title2: 'Profil', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const MsuperAdminRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/m-index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/m-user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  },
  {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/m-product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/m-product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/m-product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/m-product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice-edit'),
      meta: { title: 'Perincian', title2: 'Perincian Invois Pembelian', icon: 'ico_purchase_invoice' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer-Master',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer-Master',
      component: () => import('@/views/customers/m-main-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/m-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/m-customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/customers/m-customers-new'),
      meta: { title: 'Tambah', title2: 'Tambah', icon: 'ico_customer' }
    }]
  }, {
    path: '/Report',
    component: Layout,
    redirect: '/Reports-Analytics',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: '/Reports-Analytics',
      component: () => import('@/views/report/m-report'),
      meta: { title: 'Laporan Am', title2: 'Laporan/Analisis' }
    }, {
      path: 'Sales-Report',
      component: () => import('@/views/report/m-sales-report'),
      meta: { title: 'Laporan Jualan', title2: 'Laporan/Analisis' }
    }, {
      path: 'Product-Sales-Report',
      component: () => import('@/views/report/m-product-sales-report'),
      meta: { title: 'Laporan Jualan Produk', title2: 'Laporan/Analisis' }
    }, {
      path: 'Laporan Transaksi Online',
      component: () => import('@/views/report/m-online-transactior-report'),
      meta: { title: 'Laporan Transaksi Online', title2: 'Laporan/Analisis' }
    }]
  },
  {
    path: '/Activity-Log',
    component: Layout,
    redirect: '/Activity_Log',
    children: [{
      path: '/Activity-Log',
      component: () => import('@/views/m-activity-record'),
      meta: { title: 'Log Aktiviti', title2: 'Log Aktiviti', icon: 'ico_activity_log' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const MbigAgentRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/m-index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/m-user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  }, {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/m-product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/m-product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/m-product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/m-product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer-Master',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer-Master',
      component: () => import('@/views/customers/m-main-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/m-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/m-customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/customers/m-customers-new'),
      meta: { title: 'Tambah', title2: 'Tambah', icon: 'ico_customer' }
    }]
  },
  {
    path: '/Reports-Analytics',
    component: Layout,
    redirect: '/Reports-Analytics',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: '/Reports_Analytics',
      component: () => import('@/views/report/m-report'),
      meta: { title: 'Laporan Am', title2: 'Laporan/Analisis' }
    }, {
      path: 'Dealers',
      hidden: true,
      component: () => import('@/views/report/m-report-dealer'),
      meta: { title: 'Dealer', title2: 'Dealer' }
    }, {
      path: 'Sales-Report',
      component: () => import('@/views/report/m-sales-report'),
      meta: { title: 'Laporan Jualan', title2: 'Laporan/Analisis' }
    }, {
      path: 'Product-Sales-Report',
      component: () => import('@/views/report/m-product-sales-report'),
      meta: { title: 'Laporan Jualan Produk', title2: 'Laporan/Analisis' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    redirect: '/Company-Profile',
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/m-company-profile'),
      meta: { title: 'Profil Syarikat', title2: 'Profil Syarikat', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const MmainDealerRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/m-index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '',
      component: () => import('@/views/m-user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  }, {
    path: '/Products',
    component: Layout,
    redirect: '/Products/Query',
    meta: { title: 'Produk', title2: 'Produk', icon: 'ico_product' },
    children: [{
      path: 'Category/Query',
      name: 'Category',
      component: () => import('@/views/product/m-product-type'),
      meta: { title: 'Kategori Produk', title2: 'Kategori Produk' }
    }, {
      path: 'Category/New',
      name: 'newCategory',
      hidden: true,
      component: () => import('@/views/product/m-product-type-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Kategori Produk' }
    }, {
      path: 'Category/Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-type-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Kategori Produk' }
    }, {
      path: 'New',
      name: 'newProducts',
      hidden: true,
      component: () => import('@/views/product/m-product-new'),
      meta: { title: 'Tambah Produk', title2: 'Tambah Produk' }
    }, {
      path: 'Edit',
      hidden: true,
      component: () => import('@/views/product/m-product-edit'),
      meta: { title: 'Perincian Produk', title2: 'Perincian Produk' }
    }, {
      path: 'Query',
      name: 'Products',
      component: () => import('@/views/product/m-product'),
      meta: { title: 'Semua Produk', title2: 'Semua Produk' }
    }]
  },
  {
    path: '/Orders',
    component: Layout,
    redirect: '/Orders/Query',
    meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-order'),
      meta: { title: 'Pesanan Pembelian', title2: 'Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'New',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-new'),
      meta: { title: 'Tambah Pesanan Pembelian', title2: 'Tambah Pesanan Pembelian', icon: 'ico_po' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-order-edit'),
      meta: { title: 'Edit Pesanan Pembelian', title2: 'Perincian Pesanan Pembelian', icon: 'ico_po' }
    }]
  },
  {
    path: '/My-Orders',
    component: Layout,
    redirect: '/My-Orders/Query',
    meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' },
    children: [{
      path: 'Query',
      component: () => import('@/views/myorder/m-purchase-order'),
      meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/myorder/m-purchase-order-edit'),
      meta: { title: 'Edit Pesanan Saya', title2: 'Perincian Pesanan', icon: 'ico_my_order' }
    }]
  },
  {
    path: '/Customers',
    component: Layout,
    redirect: '/Customers/Dealer',
    meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' },
    children: [{
      path: 'Dealer',
      hidden: true,
      component: () => import('@/views/customers/m-customers'),
      meta: { title: 'Pelanggan', title2: 'Pelanggan', icon: 'ico_customer' }
    }, {
      path: 'Detail',
      hidden: true,
      component: () => import('@/views/customers/m-customers-edit'),
      meta: { title: 'edit', title2: 'Edit', icon: 'ico_customer' }
    }]
  },
  {
    path: '/Shop',
    component: Layout,
    redirect: '/Shop/Query',
    meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' },
    children: [{
      path: 'Query',
      name: 'queryShop',
      component: () => import('@/views/shop/m-shop'),
      meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' }
    }, {
      path: 'Shopping-Cart',
      hidden: true,
      component: () => import('@/views/shop/m-shop-cart'),
      meta: { title: 'Troli Beli Belah', title2: 'Troli', icon: 'ico_shop' }
    }, {
      path: 'detail/:id',
      hidden: true,
      component: () => import('@/views/shop/m-shop-detail'),
      meta: { title: 'Perincian', title2: 'Perincian Barang', icon: 'ico_shop' }
    }, {
      path: 'Checkou',
      hidden: true,
      component: () => import('@/views/shop/m-shop-checkout'),
      meta: { title: 'Semak Keluar', title2: 'Semak Keluar', icon: 'ico_shop' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice-edit'),
      meta: { title: 'Perincian', title2: 'Perincian Invois Pembelian', icon: 'ico_purchase_invoice' }
    }]
  }, {
    path: '/Reports-Analytics',
    component: Layout,
    redirect: '/Reports-Analytics',
    meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' },
    children: [{
      path: '/Reports-Analytics',
      hidden: true,
      component: () => import('@/views/report/m-report-dealer'),
      meta: { title: 'Laporan/Analisis', title2: 'Laporan/Analisis', icon: 'ico_report' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/m-company-profile'),
      meta: { title: 'Profil Syarikat', title2: 'Profil Syarikat', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
export const MsmallDealerRoutes = [
  {
    path: '/Dashboard',
    component: Layout,
    children: [{
      path: '/Dashboard',
      component: () => import('@/views/dashboard/m-index'),
      meta: { title: 'Papan Pemuka', title2: 'Papan Pemuka', icon: 'ico_dashboard' }
    }]
  }, {
    path: '/userInfo',
    component: Layout,
    hidden: true,
    children: [{
      path: '/userInfo',
      component: () => import('@/views/m-user-info'),
      meta: { title: 'Infomasi Pengguna', title2: 'Infomasi Pengguna', icon: 'userInfo' }
    }]
  },
  {
    path: '/My-Orders',
    component: Layout,
    redirect: '/My-Orders/Query',
    meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' },
    children: [{
      path: 'Query',
      component: () => import('@/views/myorder/m-purchase-order'),
      meta: { title: 'Pesanan Saya', title2: 'Pesanan Saya', icon: 'ico_my_order' }
    }, {
      path: 'Edit/:id',
      hidden: true,
      component: () => import('@/views/myorder/m-purchase-order-edit'),
      meta: { title: 'Edit Pesanan Saya', title2: 'Perincian Pesanan', icon: 'ico_my_order' }
    }]
  },
  {
    path: '/Shop',
    component: Layout,
    redirect: '/Shop/Query',
    meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' },
    children: [{
      path: 'Query',
      name: 'queryShop',
      component: () => import('@/views/shop/m-shop'),
      meta: { title: 'Kedai', title2: 'Kedai', icon: 'ico_shop' }
    }, {
      path: 'Shopping-Cart',
      hidden: true,
      component: () => import('@/views/shop/m-shop-cart'),
      meta: { title: 'Troli Beli Belah', title2: 'Troli', icon: 'ico_shop' }
    }, {
      path: 'detail/:id',
      hidden: true,
      component: () => import('@/views/shop/m-shop-detail'),
      meta: { title: 'Perincian', title2: 'Perincian Barang', icon: 'ico_shop' }
    }, {
      path: 'Checkou',
      hidden: true,
      component: () => import('@/views/shop/m-shop-checkout'),
      meta: { title: 'Semak Keluar', title2: 'Semak Keluar', icon: 'ico_shop' }
    }]
  },
  {
    path: '/Invoices',
    component: Layout,
    redirect: '/Invoices/Query',
    meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' },
    children: [{
      path: 'Query',
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice'),
      meta: { title: 'Invois Pembelian', title2: 'Invois Pembelian', icon: 'ico_purchase_invoice' }
    }, {
      path: 'Detail/:id',
      hidden: true,
      component: () => import('@/views/invoiceorder/m-purchase-lnvoice-edit'),
      meta: { title: 'Perincian', title2: 'Perincian Invois', icon: 'ico_purchase_invoice' }
    }]
  },
  {
    path: '/Company-Profile',
    component: Layout,
    redirect: '/Company-Profile',
    children: [{
      path: '/Company-Profile',
      component: () => import('@/views/m-company-profile'),
      meta: { title: 'Profil Saya', title2: 'Profil', icon: 'el-icon-time' }
    }]
  },
  { path: '*', redirect: '404', hidden: true }
]
